package com.macro.mall.controller;

import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.service.HomeStatisticalService;
import com.macro.mall.vo.OrderTotalVO;
import com.macro.mall.vo.StatisticalVO;
import com.macro.mall.vo.TodayOrderTotalVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "HomeController", description = "首页管理")
@RequestMapping("/home")
public class HomeController {
    @Autowired
    private HomeStatisticalService homeStatisticalService;
    @ApiOperation("数据统计")
    @GetMapping("/statistical/list")
    public CommonResult<StatisticalVO> statistical(){
        return CommonResult.success(homeStatisticalService.list());
    }
    @ApiOperation("订单统计")
    @GetMapping("/monthOrderTotal")
    public CommonResult<OrderTotalVO> monthOrderStatistical(){
        return CommonResult.success(homeStatisticalService.monthOrderStatistical());
    }
    @ApiOperation("根据时间段统计订单")
    @GetMapping("/timeOrderTotal")
    public CommonResult<List<TodayOrderTotalVO>> timeOrderTotal(@RequestParam(value = "start") String start,
                                                                @RequestParam(value = "end") String end){
        return CommonResult.success(homeStatisticalService.timeOrderTotal(start,end));
    }
}
